class FieldSelectField {

    constructor(public info: FieldSelect<any>, public fieldName: string) {

    }

    toString() {
        this.info.valList.push(this.fieldName);
        return this.fieldName;
    }

    valueOf() {
        this.info.valList.push(this.fieldName);
        return this.fieldName;
    }

    eq(v: any) {
        this.info.valList.push(this.fieldName);
        this.info.funcList.push(v);
        return 1;
    }

    $eq(v: any) {
        return this.eq(v);
    }
}

/**
 * 属性选择器
 */
export class FieldSelect<T> {
    obj: any;
    //属性列表
    valList: string[] = [];
    //属性列表
    funcList: any[] = [];

    constructor(public className: {new(): T}) {
        this.obj = new className();
        for (let k in this.obj) {
            this.obj[k] = new FieldSelectField(this, k);
        }
    }

    select(func: (f: T)=>any) {
        this.valList = [];
        this.funcList = [];
        let ret = func(this.obj);
        if (ret instanceof FieldSelectField)
            ret.toString();
    }

}
